package com.demo.component;

import com.demo.model.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

@Component
public class StudentBeans {

    @Bean(name = {"s1","s2"})
    // 是将方法返回的对象存入Spring中,注解也是在方法上的！！
    public Student stu() {
        // 伪代码，构建对象
        Student student = new Student();
        // 调用set方法
        student.setId(1);
        student.setName("小周");
        student.setAge(16);
        return student;
    }
}
